<?php
/**
 * Created by PhpStorm.
 * User: iyahe@qq.com (天明)
 * Date: 2018/1/24
 * Time: 16:51
 */
require_once dirname(__DIR__).'/vendor/autoload.php';
use QL\QueryList;




if(false){
        if(false){
            $allImgs = [];
            for ($i = 1; $i <=5 ; $i++) {
                $url = 'http://www.win4000.com/zt/wangzherongyao_'.$i.'.html';
                print_r($url);
                sleep(2);
                $html = file_get_contents($url);
                $rules = array(
                    'text' => array('.tab_box ul.clearfix li a','alt'),
                    'img' => array('.tab_box ul.clearfix li a img','src'),
                    'href' => array('.tab_box ul.clearfix li a','href'),
                );
                $data = QueryList::Query($html,$rules)->getData(function($item){
                    if($item['text']) {
                        return $item;
                    }
                });
                foreach ($data as $k=>$v){
                    if(!$v){
                        unset($data[$k]);
                    }else{
                        array_push($allImgs,$v);
                    }
                }
                sleep(2);
            }
            print_r($allImgs);
            file_put_contents('imgs.json',json_encode($allImgs,JSON_UNESCAPED_UNICODE));
        }
        else{
            $json = file_get_contents('imgs.json');
            $arr = json_decode($json,true);
            $allImgs = [];
            for ($i = 0; $i < count($arr); $i++) {
                $html = file_get_contents($arr[$i]['href']);
                $rules = array(
                    'img' => array('.pic-large','src'),
                    'title' => array('.pic-large','title'),
                );
                $data = QueryList::Query($html,$rules)->getData();
                array_push($allImgs,$data);
                print_r($data);
            }
            file_put_contents('imgContent.json',json_encode($allImgs,JSON_UNESCAPED_UNICODE));
        }

    }

$arrs = [];
for ($i = 0; $i <= 11; $i++) {
    $url = 'http://apps.game.qq.com/cgi-bin/ams/module/ishow/V1.0/query/workList_inc.cgi?activityId=2735&sVerifyCode=ABCD&sDataType=JSON&iListNum=20&totalpage=0&page='.$i.'&iOrder=0&iSortNumClose=1&iAMSActivityId=51991&_everyRead=true&iTypeId=2&iFlowId=267733&iActId=2735&iModuleId=2735&_=1516786465727';
    $json = file_get_contents($url);
    $jsonArr = json_decode($json,true)['List'];
    for ($j = 0; $j < count($jsonArr); $j++) {
        array_push($arrs,array(
            'imgs'=>urldecode($jsonArr[$j]['sProdImgNo_1']),
            'thumb'=>urldecode($jsonArr[$j]['sThumbURL']),
            'sProdName'=>urldecode($jsonArr[$j]['sProdName'])
        ));
    }
    print_r($i);
}
file_put_contents('teImg.json',json_encode($arrs,JSON_UNESCAPED_UNICODE));




